package mytest.simple.watcher;

import java.util.concurrent.CountDownLatch;

import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.ZooKeeper;
import org.junit.Before;
import org.junit.Test;

import mytest.simple.SimpleWatcher;

public class WatcherTest2 {
	private ZooKeeper zookeeper;
	private String path = "/watcher";
	
	@Before
	public void before() {
		try {
			//才连接的时候也会触发一次watcher
			zookeeper = new ZooKeeper("127.0.0.1:2184", 5000, new SimpleWatcher());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@Test
	public void setData() throws Exception {
		zookeeper.setData(path, "foo".getBytes(), 0);
	}
	
	@Test
	public void testDelete() throws Exception {
		zookeeper.delete(path, -1);
	}
	
}
